// 入参
//  :title="title" dialog标题
//  :label="dialogLabel" 名称
//  :params="params" 参数
<template>
  <el-dialog
    width="30%"
    :title="title"
    :visible.sync="checkVisible"
    append-to-body
  >
    <el-form
      ref="form"
      label-width="80px"
      :model="formDatas"
    >
      <el-form-item :label="label" label-width="90px">
        <el-input v-model="formDatas.name" />
      </el-form-item>
    </el-form>
    <span
      slot="footer"
      class="dialog-footer"
    >
      <el-button
        size="mini"
        @click="dialogClose"
      >取 消</el-button>
      <el-button
        size="mini"
        type="primary"
        @click="dialogConfirm"
      >确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
// import { addGroup, setGroup } from '@/api/agent'
export default {
  name: 'SingleInputDialog',
  props: {
    params: {
      type: Object,
      default: function() {
        return ''
      }
    },
    title: {
      type: String,
      default: '弹窗'
    },
    width: {
      type: String,
      default: '70%'
    },
    label: {
      type: String,
      default: '名称'
    }
  },
  data() {
    return {
      checked: false,
      checkVisible: false,
      formData: {},
      //   表格数据
      formDatas: {
        name: ''
      }
    }
  },
  methods: {
    open(ok) {
      this.formData = this._.cloneDeep(this.params)
      this.ok = ok
      this.checkVisible = true
      // this.formData.name = ''
      // if (this.formDatas.name !== undefined) {
      this.formDatas.name = this.formData[0].text
      // }
    },
    dialogClose() {
      this.checkVisible = false
    },
    dialogConfirm() {
      this.checkVisible = false
      this.ok(this.formDatas.name)
      this.$emit('returnData', this.formDatas.name)
    }
  }
}
</script>
